package cn.jdw.shop;

import cn.jdw.shop.product.entity.Commodity;
import cn.jdw.shop.product.service.ICommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author ListJiang
 * datetime: 2021/10/8 8:20
 */
@SpringBootApplication
@Controller
public class ShoppingApplication {

    @Autowired
    private ICommodityService iCommodityService;

    /**
     * 项目启动
     *
     * @param args 启动参数
     */
    public static void main(String[] args) {
        SpringApplication.run(ShoppingApplication.class, args);
    }

    /**
     * @return index page
     */
    @RequestMapping("/")
    public String s() {
        iCommodityService.list();
        return "index";
    }

    /**
     * @return list 测试
     */
    @GetMapping("/list")
    @ResponseBody
    public Object list() {
        return iCommodityService.list();
    }

    /**
     * @return list 测试
     */
    @PostMapping("/list")
    @ResponseBody
    public Object list2(@RequestBody Commodity commodity) {
        System.out.println(commodity);
        return iCommodityService.list();
    }

}